﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Settings.Configuration;

namespace Gateway.Logger
{
    public static class LoggerExtension
    {
        public static void UseLogger(this IHostBuilder builder, IConfiguration configuration)
        {
            builder.UseSerilog((context, logger) =>
            {
                //Serilog读取配置
                var loggerConfiguration = logger.ReadFrom.Configuration(context.Configuration);    
                logger.Enrich.FromLogContext();
                logger.Enrich.WithThreadId();
                logger.Enrich.WithThreadName();
                logger.Enrich.WithMachineName();
            });
        }
    }
}
